﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using ArchPostprocessing.CompoundStructureManage.DataDefinition;
using ArchPostprocessing.CompoundStructureManage.Managers;
using Autodesk.Revit.DB;
using YArchitech.LIB;

namespace ArchPostprocessing.CompoundStructureManage.Forms
{
	public partial class CompoundStructureSettingForm : System.Windows.Forms.Form
	{
		public CompoundStructureSettingForm(Autodesk.Revit.DB.Document doc, List<WallLayerInfos> wallTypeLayerInfos)
		{
			this.InitializeComponent();
			this.m_Doc = doc;
			this.m_CommonForm = new CompoundStructureCommonForm(base.Handle, doc, wallTypeLayerInfos);
		}

		public List<WallLayerInfos> WallLayerInfo
		{
			get
			{
				return this.m_CommonForm.CurrentWallLayerInfo;
			}
		}

		private void CompoundStructureSettingForm_Load(object sender, EventArgs e)
		{
			base.Icon = Resource.YArchitechIcon;
			this.m_CommonForm.TopLevel = false;
			this.m_CommonForm.Parent = this.panelMain;
			this.m_CommonForm.Show();
		}

		private void CompoundStructureSettingForm_FormClosing(object sender, FormClosingEventArgs e)
		{
			if (((System.Windows.Forms.Form)sender).DialogResult != DialogResult.OK)
			{
				return;
			}
			List<WallLayerInfos> currentWallLayerInfo = this.m_CommonForm.CurrentWallLayerInfo;
			List<CompoundStructureLayer> list = new List<CompoundStructureLayer>();
			foreach (WallLayerInfos wallLayerInfos in currentWallLayerInfo)
			{
				list.Add(wallLayerInfos.StructureLayer);
			}
			string text = "";
			if (!WallTypeManager.IsValidWithLayers(list, this.m_Doc, ref text))
			{
				MessageBox.Show(text, "盈建科提示");
				e.Cancel = true;
			}
			this.m_CommonForm.Update();
		}

		private CompoundStructureCommonForm m_CommonForm;

		private Document m_Doc;
	}
}
